/**
 * All rights reserved by www.xmerge.cn
 */
package net.xfok.info.ecup;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

import net.xfok.string.filter.Regex;

/**
 * @author YangHua
 *
 */
public class InfoConstant {
	public static String infoType="ecup";
	public static String rss="http://vdap.soso.com/rss?tag=1&src=-10&ofmt=xml&kd=n&full=1&w=%C5%B7%B9%DA";
	public static int alarmTime=30*60*1000;
	public static int pageSize=5;
	public static SimpleDateFormat idf = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");

	public static Date strToDate(String strDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(strDate, pos);
		return strtodate;
	}
	
	public static String dateToStr(Date dateDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		String dateString = formatter.format(dateDate);
		return dateString;
	}
	
	public static String getNextDay(String now, int delay) {
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			String mdate = "";
			Date d = strToDate(now);
			long myTime = (d.getTime() / 1000) + delay * 24 * 60 * 60;
			d.setTime(myTime * 1000);
			mdate = format.format(d);
			return mdate;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static String filter(String str){
		  for(String s:Regex.genStrByReg(str, Regex.REG_HTML)){
			  str=str.replace(s, "");  
		  }
		  str=str.replace("'", "''");
		  return str.trim();
	 } 	
    
	public static boolean isBigger(String date1,String date2){
		return strToDate(date1).getTime()>strToDate(date2).getTime();
	}
}
